package com.biyeshengjiuye.service.impl;


import com.biyeshengjiuye.dao.UserEnterMapper;
import com.biyeshengjiuye.entity.Enterprise;
import com.biyeshengjiuye.service.UserEnterService;
import com.biyeshengjiuye.utils.PasswordUtil;
import com.biyeshengjiuye.utils.SystemConstant;
import com.biyeshengjiuye.vo.EnterVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class UserEnterServiceImpl implements UserEnterService {

    @Resource
    private UserEnterMapper userEnterMapper;
    public List<Enterprise> findEnterpriseByPageById(EnterVo enterVo) {
        return userEnterMapper.findEnterpriseByPageById(enterVo);
    }

    public int addEnterprise(Enterprise enterprise) {
        String newPassword = PasswordUtil.md5(SystemConstant.DEFAULT_LOGIN_PWD, enterprise.getE_id(), SystemConstant.PASSWORD_COUNT);
        enterprise.setE_password(newPassword);
        return userEnterMapper.addEnterprise(enterprise);
    }

    public int updateEnterprise(Enterprise enterprise) {
        return userEnterMapper.updateEnterprise(enterprise);
    }

    public int deleteById(String e_id) {
        return userEnterMapper.deleteById(e_id);
    }
}
